package co.yixiang.yshop.module.crm.controller.admin.crmcloudcalllog;

import org.springframework.web.bind.annotation.*;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;

import jakarta.validation.constraints.*;
import jakarta.validation.*;
import jakarta.servlet.http.*;
import java.util.*;
import java.io.IOException;

import co.yixiang.yshop.framework.common.pojo.PageParam;
import co.yixiang.yshop.framework.common.pojo.PageResult;
import co.yixiang.yshop.framework.common.pojo.CommonResult;
import co.yixiang.yshop.framework.common.util.object.BeanUtils;
import static co.yixiang.yshop.framework.common.pojo.CommonResult.success;

import co.yixiang.yshop.framework.excel.core.util.ExcelUtils;

import co.yixiang.yshop.framework.apilog.core.annotation.ApiAccessLog;
import static co.yixiang.yshop.framework.apilog.core.enums.OperateTypeEnum.*;

import co.yixiang.yshop.module.crm.controller.admin.crmcloudcalllog.vo.*;
import co.yixiang.yshop.module.crm.dal.dataobject.crmcloudcalllog.CrmCloudcallLogDO;
import co.yixiang.yshop.module.crm.service.crmcloudcalllog.CrmCloudcallLogService;

@Tag(name = "管理后台 - 呼叫记录")
@RestController
@RequestMapping("/crm/cloudcall-log")
@Validated
public class CrmCloudcallLogController {

    @Resource
    private CrmCloudcallLogService cloudcallLogService;




    @DeleteMapping("/delete")
    @Operation(summary = "删除呼叫记录")
    @Parameter(name = "id", description = "编号", required = true)
    @PreAuthorize("@ss.hasPermission('crm:cloudcall-log:delete')")
    public CommonResult<Boolean> deleteCloudcallLog(@RequestParam("id") Long id) {
        cloudcallLogService.deleteCloudcallLog(id);
        return success(true);
    }

    @GetMapping("/get")
    @Operation(summary = "获得呼叫记录")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    @PreAuthorize("@ss.hasPermission('crm:cloudcall-log:query')")
    public CommonResult<CrmCloudcallLogRespVO> getCloudcallLog(@RequestParam("id") Long id) {
        CrmCloudcallLogDO cloudcallLog = cloudcallLogService.getCloudcallLog(id);
        return success(BeanUtils.toBean(cloudcallLog, CrmCloudcallLogRespVO.class));
    }

    @GetMapping("/page")
    @Operation(summary = "获得呼叫记录分页")
    @PreAuthorize("@ss.hasPermission('crm:cloudcall-log:query')")
    public CommonResult<PageResult<CrmCloudcallLogRespVO>> getCloudcallLogPage(@Valid CrmCloudcallLogPageReqVO pageReqVO) {
        return success(cloudcallLogService.getCloudcallLogPage(pageReqVO));
    }



}